class Solution:
  def myPow(self, x: float, n: int) -> float:
    if n == 0:
      return 1
    if n < 0:
      x = 1 / x
      n = -n
    res = 1
    while n:
      if n & 1:         # 检测一个数是否是奇数的位运算方法
        res = res * x
      x = x * x
      n = n >> 1
    return res


'''
STATUS: LEARNT
TRIES:  N/A
TIME:   36 MS
MEMORY: 13.7 MB
'''
if __name__ == "__main__":
  solution = Solution()
  print(solution.myPow(2, 1024))